package grape.attend.rest.user.mvc;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.validation.Valid;
import grape.attend.rest.user.form.UserClockDateClasseCreateForm;
import grape.attend.rest.user.form.UserClockDateClasseUpdateForm;
import grape.attend.rest.user.form.UserClockDateClasseListPageForm;
import grape.attend.rest.user.vo.UserClockDateClasseVo;
import grape.attend.rest.user.mapper.UserClockDateClasseWebMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import grape.common.rest.mvc.BaseController;
import grape.attend.service.user.po.UserClockDateClasse;
import grape.attend.service.user.api.IUserClockDateClasseService;
import java.util.List;
/**
 * <p>
 * 用户打卡日期班次表 前端控制器
 * </p>
 *
 * @author yangwei
 * @since 2020-05-25
 */
@RestController
@RequestMapping("/attend/userclockdateclasse")
@Api(tags = "用户打卡日期班次表相关接口")
public class UserClockDateClasseController extends BaseController<UserClockDateClasseVo, UserClockDateClasse> {

    @Autowired
    private UserClockDateClasseWebMapper currentWebMapper;
    @Autowired
    private IUserClockDateClasseService currentService;



     @ApiOperation("添加用户打卡日期班次表")
     @PreAuthorize("hasAuthority('userclockdateclasse:single:create')")
     @PostMapping
     @ResponseStatus(HttpStatus.CREATED)
     public UserClockDateClasseVo create(@RequestBody @Valid UserClockDateClasseCreateForm cf) {
         UserClockDateClasse po = currentWebMapper.formToPo(cf);
         return super.create(po);
     }

     @ApiOperation("根据ID查询用户打卡日期班次表")
     @PreAuthorize("hasAuthority('userclockdateclasse:single:queryById')")
     @GetMapping("/{id}")
     @ResponseStatus(HttpStatus.OK)
     public UserClockDateClasseVo queryById(@PathVariable String id) {
         return super.queryById(id);
     }

     @ApiOperation("删除用户打卡日期班次表")
     @PreAuthorize("hasAuthority('userclockdateclasse:single:deleteById')")
     @DeleteMapping("/{id}")
     @ResponseStatus(HttpStatus.NO_CONTENT)
     public boolean deleteById(@PathVariable String id) {
         return super.deleteById(id);
     }

     @ApiOperation("更新用户打卡日期班次表")
     @PreAuthorize("hasAuthority('userclockdateclasse:single:updateById')")
     @PutMapping("/{id}")
     @ResponseStatus(HttpStatus.CREATED)
     public UserClockDateClasseVo update(@PathVariable String id,@RequestBody @Valid UserClockDateClasseUpdateForm uf) {
         UserClockDateClasse po = currentWebMapper.formToPo(uf);
         po.setId(id);
         return super.update(po);
     }

    @ApiOperation("分页查询用户打卡日期班次表")
    @PreAuthorize("hasAuthority('userclockdateclasse:single:listPage')")
    @GetMapping("/listPage")
    @ResponseStatus(HttpStatus.OK)
    public IPage<UserClockDateClasseVo> listPage(UserClockDateClasseListPageForm listPageForm) {
         UserClockDateClasse po = currentWebMapper.formToPo(listPageForm);
         return super.listPage(po,listPageForm);
     }

}
